﻿<Page x:Class="PasswordProvider.View.SetPasswordPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:lib="clr-namespace:PasswordProvider.View.Library"
    Title="{Binding DisplayName}"
    ToolTip="{Binding ToolTip}"
    FocusManager.FocusedElement="{Binding ElementName=mainPasswordBox}"
    >
	<Grid>
		<Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
            <RowDefinition />
		</Grid.RowDefinitions>        

        <TextBlock Grid.Row="0" TextWrapping="Wrap" Margin="10,5,10,0" 
                   Visibility="{Binding FirstTimeMessage.Visibility}"
                   Text="{Binding FirstTimeMessage.DisplayName}" />        
        
        <TextBlock Grid.Row="1" TextWrapping="Wrap" Margin="10,5,10,3"
                   Text="{Binding PasswordMain.DisplayName}" />
        
        <lib:BindablePasswordBox x:Name="mainPasswordBox"
                     Grid.Row="2" Margin="10,0,40,0" VerticalAlignment="Center"
                     SecurePassword="{Binding PasswordMain.Password, Mode=OneWayToSource}"/>
        
        <lib:BindablePasswordBox Grid.Row="3" Margin="10,5,40,0" VerticalAlignment="Center"
                     IsEnabled="{Binding PasswordVerify.IsEnabled}"
                     SecurePassword="{Binding PasswordVerify.Password, Mode=OneWayToSource}"/>
        
        <TextBlock Grid.Row="4" TextWrapping="Wrap" TextAlignment="Left" Margin="10,15,10,0"
                   Text="{Binding NumberOfIterations.DisplayName}" />

        <TextBox Grid.Row="5" Margin="10,3" Width="80" VerticalAlignment="Top" HorizontalAlignment="Left"
                 ToolTip="{Binding NumberOfIterations.ToolTip}"
                 Text="{Binding NumberOfIterations.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
       
        <TextBlock Grid.Row="6" VerticalAlignment="Top" Margin="10"
                   Foreground="Red" Background="Transparent"
                   Text="{Binding Error}" />
        
        <Button Grid.Row="7" Margin="10" Width="50" VerticalAlignment="Bottom" HorizontalAlignment="Right"
                IsDefault="{Binding Path=ApplyCommand.IsDefault}"
                Content="{Binding Path=ApplyCommand.DisplayName}"
                Command="{Binding Path=ApplyCommand.Command}"
                />
    
	</Grid>
</Page>
